package com.styytech.dadabao.api.requestresult;

import com.styytech.dadabao.api.response.AbstractResponseResult;
import com.styytech.dadabao.bean.ListData;
import com.styytech.dadabao.utils.ParseJsonUtils;

import org.json.JSONArray;

/**
 * 获取银行卡列表请求
 */
public class BankcardListResult extends RequestResult {
    private int dataType;

    /**
     * 构造函数
     *
     * @param httpResponseResult
     * @param dataType           请求的数据类型
     */
    public BankcardListResult(AbstractResponseResult httpResponseResult, int dataType) {
        super(httpResponseResult);
        this.dataType = dataType;
    }

    @Override
    public void doBusiness() {
        super.doBusiness();
        if (super.isSuccess()) {
            JSONArray jsonArray = (JSONArray) super.getRows();
            dataParse(jsonArray);
        }
    }

    private void dataParse(JSONArray jsonArray) {
        ListData listData = ParseJsonUtils.ParseListData(jsonArray, dataType);
//        listData.setPageNum(super.getPage());
//        listData.setTotlePageNum(super.getPages());
        if (httpResponseResult != null) {
            httpResponseResult.executeSuccess(listData);
        }
    }
}
